<html>
<head><meta charset="utf-8"><title>chalk crates · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html">chalk crates</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163463589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163463589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163463589">(Apr 16 2019 at 12:19)</a>:</h4>
<p>So I was thinking over what <span class="user-mention" data-user-id="133169">@matklad</span> wrote and I have a proposal for a simpler organization of the crates -- but to start, I filed <a href="https://github.com/rust-lang/chalk/issues/212" target="_blank" title="https://github.com/rust-lang/chalk/issues/212">https://github.com/rust-lang/chalk/issues/212</a> -- I thought <span class="user-mention" data-user-id="125131">@detrumi</span> you might be interested in this as a "starter refactoring".</p>



<a name="163463952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163463952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163463952">(Apr 16 2019 at 12:24)</a>:</h4>
<p>Yeah sounds good. Coinductive traits sound a bit scary, but I see that they're documented in rustc-guide, so that helps <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="163468348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163468348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163468348">(Apr 16 2019 at 13:22)</a>:</h4>
<p>Heh, I've yet to find anyone who really claims to understand coinduction ;)</p>



<a name="163491412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163491412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163491412">(Apr 16 2019 at 17:56)</a>:</h4>
<p>heh, <span class="user-mention" data-user-id="125131">@detrumi</span>, you're fast <a href="https://github.com/rust-lang/chalk/pull/213" target="_blank" title="https://github.com/rust-lang/chalk/pull/213">https://github.com/rust-lang/chalk/pull/213</a> :)</p>



<a name="163491429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163491429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163491429">(Apr 16 2019 at 17:56)</a>:</h4>
<p>I'm hoping to create some follow-up plans tonight</p>



<a name="163491778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163491778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163491778">(Apr 16 2019 at 18:00)</a>:</h4>
<p>You mentioned it would be straightforward, but I didn't expect it to be that easy</p>



<a name="163494046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163494046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163494046">(Apr 16 2019 at 18:26)</a>:</h4>
<p>Just a softball ;)</p>



<a name="163494623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163494623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163494623">(Apr 16 2019 at 18:33)</a>:</h4>
<p>OK, I started writing up <a href="https://github.com/rust-lang/chalk/issues/214" target="_blank" title="https://github.com/rust-lang/chalk/issues/214">https://github.com/rust-lang/chalk/issues/214</a> but I didn't finish</p>



<a name="163494626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163494626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163494626">(Apr 16 2019 at 18:33)</a>:</h4>
<p>will do a bit more later</p>



<a name="163494872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163494872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163494872">(Apr 16 2019 at 18:36)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> am I correct that the <code>chalk</code> crate is actually a test harness for chalk?  Would it be a good idea to rename it to <code>chalk-tester</code>, and have the public API crate named just <code>chalk</code>?</p>



<a name="163494909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163494909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163494909">(Apr 16 2019 at 18:36)</a>:</h4>
<p>Probably, yes</p>



<a name="163500028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163500028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163500028">(Apr 16 2019 at 19:38)</a>:</h4>
<p>Ok I finished my write-up in <a href="https://github.com/rust-lang/chalk/issues/214" target="_blank" title="https://github.com/rust-lang/chalk/issues/214">https://github.com/rust-lang/chalk/issues/214</a> (cc <span class="user-mention" data-user-id="133169">@matklad</span>, <span class="user-mention" data-user-id="131694">@scalexm</span>, <span class="user-mention" data-user-id="116883">@tmandry</span> -- not sure who else). I'm not sure how clear it is, though, and the final set of steps are in particular incomplete. This is because I am wondering. Maybe it makes sense, at least for now, to collapse chalk-solve and chalk-rules into one crate. This would simplify things somewhat, and might make the transition a bit easier too. At least there would be fewer crates and intermediaries.</p>
<p>The main value I see in separating out the chalk-rules code is that we <em>might</em> be able to reuse it from rustc, with a bit more refactoring. But I'm not sure if that's a very good goal. Maybe it's better to shoot for having rustc (and chalk) share chalk-ir, so it can reuse the whole solver infrastructure, which would really be ideal (this is what I expect the RLS to do).</p>
<p>Moreover, it might be worth collapsing them <strong>for now</strong> and then trying to tease them apart only if we later want rustc to reuse the chalk-rules code but not chalk-ir.</p>



<a name="163501490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163501490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163501490">(Apr 16 2019 at 19:55)</a>:</h4>
<p>The more I think about it, the more I think I should rewrite that, but with the perspective of merging chalk-solve and chalk-rules for now</p>



<a name="163501502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163501502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163501502">(Apr 16 2019 at 19:56)</a>:</h4>
<p>I think it would make things mildly easier and we can always tease them apart again</p>



<a name="163501772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163501772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163501772">(Apr 16 2019 at 19:59)</a>:</h4>
<p>Don't really have  a lot of context here, but, <strong>if</strong> integrating with rls is far easier than with rustc, it makes sense to merge, integrate in rls, and then tease apart, <em>informed</em> by the integration experience.</p>



<a name="163501801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163501801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163501801">(Apr 16 2019 at 19:59)</a>:</h4>
<p>/me really just wants cool completions in rust-analyzer :D</p>



<a name="163509324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509324">(Apr 16 2019 at 21:35)</a>:</h4>
<p>If we merge the two crates into one, I think the steps would be roughly like this:</p>
<ul>
<li>Merge the two crates directly, replacing <code>ChalkRulesDatabase</code> with <code>ChalkSolveDatabase</code>.</li>
<li>Remove the <code>is_coinductive</code> method from <code>ChalkSolveDatabase</code>, since it can now be implemented directly in chalk-solve.</li>
<li>Remove the <code>GoalSolver</code> trait -- instead, the <code>coherence/wf</code> code can take a <code>SolverChoice</code> (kind of like it used to, actually) and a <code>db: &amp;dyn ChalkSolveDatabase</code>.  It can then instantiate a solver explicitly.<ul>
<li>we probably to keep the <code>ChalkDatabase</code> type having a <code>solve</code> method just like it does today, it just wouldn't implement <code>GoalSolver</code>, it would be an inherent method</li>
</ul>
</li>
<li>Then we remove the <code>program_clauses_that_could_match</code> method and replace it with the more targeted code from rustc</li>
</ul>



<a name="163509334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509334">(Apr 16 2019 at 21:35)</a>:</h4>
<p>This is mildly easier than the other way because the chalk-rules code can require <code>ChalkSolveDatabase</code></p>



<a name="163509340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509340">(Apr 16 2019 at 21:35)</a>:</h4>
<p>But I suppose it's not really all that different</p>



<a name="163509455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509455">(Apr 16 2019 at 21:37)</a>:</h4>
<blockquote>
<p>Coinductive traits sound a bit scary</p>
</blockquote>
<p>I wonder if "coinductive trait" is a bit of a misnomer, as there doesn't seem to be anything (co)inductive about traits at all</p>



<a name="163509515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509515">(Apr 16 2019 at 21:38)</a>:</h4>
<p>it's really the auto bounds that are checked corecursively</p>



<a name="163509549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509549">(Apr 16 2019 at 21:39)</a>:</h4>
<p>(I'm not sure where the naming came from initially, so maybe there's another reason behind it)</p>



<a name="163509624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509624">(Apr 16 2019 at 21:40)</a>:</h4>
<p>I confess I had not heard the term corecursive before</p>



<a name="163509650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509650">(Apr 16 2019 at 21:40)</a>:</h4>
<p>I think there are other ways to think about auto traits, but from what I understand of co-induction, it seems like a reasonably good fit</p>



<a name="163509658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509658">(Apr 16 2019 at 21:40)</a>:</h4>
<p>I think the terms recursion/induction are often used in very similar contexts anyway</p>



<a name="163509669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509669">(Apr 16 2019 at 21:41)</a>:</h4>
<p>Still, this would probably be a useful topic to discuss more deeply! (Though in a separate zulip topic, perhaps)</p>



<a name="163509700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509700">(Apr 16 2019 at 21:42)</a>:</h4>
<p>(I think that one wouldn't call a normal trait "inductive", which is analogous to calling an auto trait "coinductive")</p>



<a name="163509778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163509778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163509778">(Apr 16 2019 at 21:42)</a>:</h4>
<p>(but that's a tangential line of thought anyway <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span> )</p>



<a name="163510381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163510381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163510381">(Apr 16 2019 at 21:52)</a>:</h4>
<p>OK, I updated <a href="https://github.com/rust-lang-nursery/chalk/issues/214" target="_blank" title="https://github.com/rust-lang-nursery/chalk/issues/214">chalk#214</a> to a simpler proposal, including some implementation steps. <span class="user-mention" data-user-id="125131">@detrumi</span> -- take a look, maybe you want to take that on?</p>



<a name="163510383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163510383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163510383">(Apr 16 2019 at 21:52)</a>:</h4>
<p>Gotta run for the time being</p>



<a name="163533275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163533275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163533275">(Apr 17 2019 at 05:41)</a>:</h4>
<p>For implementing <code>is_coinductive</code>directly in <code>chalk-solve</code> (assuming you mean <code>is_coinductive_trait</code>), would that become a method on <code>Program</code> then?</p>



<a name="163544869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163544869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163544869">(Apr 17 2019 at 09:26)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> ah, yeah, I wasn't very specific about that. It should not be a method on <code>Program</code>, as chalk-solve has no access to <code>Program</code>. Rather, we would modify <a href="https://github.com/rust-lang/chalk/blob/eb1ed91c944b8e4f12b36299b3692b357724f596/chalk-solve/src/coinductive_goal.rs#L20" target="_blank" title="https://github.com/rust-lang/chalk/blob/eb1ed91c944b8e4f12b36299b3692b357724f596/chalk-solve/src/coinductive_goal.rs#L20">this call here</a> and inline the definition</p>



<a name="163545079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163545079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163545079">(Apr 17 2019 at 09:29)</a>:</h4>
<p>But inlining will also call <code>db.program_ir()</code>to get the <code>Program</code>, right?</p>



<a name="163545313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163545313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163545313">(Apr 17 2019 at 09:32)</a>:</h4>
<p>No</p>



<a name="163545317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163545317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163545317">(Apr 17 2019 at 09:32)</a>:</h4>
<p>it should just call <code>db.trait_datum()</code></p>



<a name="163545323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163545323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163545323">(Apr 17 2019 at 09:32)</a>:</h4>
<p>since <code>db</code> will now implement <code>RustIrSource</code></p>



<a name="163545388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163545388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163545388">(Apr 17 2019 at 09:33)</a>:</h4>
<p>Ah, of course</p>



<a name="163686120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163686120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163686120">(Apr 18 2019 at 20:06)</a>:</h4>
<p>Looking into rustc's <code>ChalkInferenceContext::program_clauses_impl</code> , I can see that <code>FromEnv</code> goals might be tricky, as they come from the environment</p>



<a name="163687692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163687692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163687692">(Apr 18 2019 at 20:25)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> yes, but we should have the info we need</p>



<a name="163687707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163687707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163687707">(Apr 18 2019 at 20:25)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> note that I had intended for that bit to be a separate PR</p>



<a name="163687716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163687716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163687716">(Apr 18 2019 at 20:25)</a>:</h4>
<p>though I may not have made that very clear :)</p>



<a name="163687726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163687726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163687726">(Apr 18 2019 at 20:25)</a>:</h4>
<p>i.e., I'd rather land the other changes and leave that one on its own</p>



<a name="163687728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163687728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163687728">(Apr 18 2019 at 20:25)</a>:</h4>
<p>as it's more complex</p>



<a name="163741488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163741488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163741488">(Apr 19 2019 at 15:08)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> left a <a href="https://github.com/rust-lang/chalk/pull/215#discussion_r277009973" target="_blank" title="https://github.com/rust-lang/chalk/pull/215#discussion_r277009973">tiny nit</a>, but other than that, I think this PR is ready to land, yeah?</p>



<a name="163744244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163744244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163744244">(Apr 19 2019 at 15:55)</a>:</h4>
<p>Yes, should be ready to go!</p>



<a name="163756214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163756214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163756214">(Apr 19 2019 at 18:53)</a>:</h4>
<blockquote>
<p>Looking into rustc's <code>ChalkInferenceContext::program_clauses_impl</code> , I can see that <code>FromEnv</code> goals might be tricky, as they come from the environment</p>
</blockquote>
<p>Do you feel like you understand what is going on here, <span class="user-mention" data-user-id="125131">@detrumi</span>?</p>



<a name="163756266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163756266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163756266">(Apr 19 2019 at 18:54)</a>:</h4>
<p>If it would be helpful, I think either <span class="user-mention" data-user-id="131694">@scalexm</span> or I could provide more details</p>



<a name="163756279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163756279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163756279">(Apr 19 2019 at 18:54)</a>:</h4>
<p>PS, I merged your PR, very nice work.</p>



<a name="163757836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163757836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163757836">(Apr 19 2019 at 19:13)</a>:</h4>
<p>(Also, <span class="user-mention" data-user-id="131694">@scalexm</span>, I'm assuming you don't object to the simplified crate hierarchy I proposed)</p>



<a name="163758414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758414">(Apr 19 2019 at 19:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> no objection apart from thinking it is a good thing</p>



<a name="163758477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758477">(Apr 19 2019 at 19:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Well, I understand what these functions are doing at a high level, and it's not too difficult to port the big match on the goal. But for some of the details it feels more like guessing than really understanding it</p>



<a name="163758531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758531">(Apr 19 2019 at 19:23)</a>:</h4>
<p>as I recall, we were half-guessing when we wrote it ;)</p>



<a name="163758534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758534">(Apr 19 2019 at 19:23)</a>:</h4>
<p>Like, I have no idea what the clause categories are in the rustc code, or what role the WellFormed checks play</p>



<a name="163758535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758535">(Apr 19 2019 at 19:23)</a>:</h4>
<p>I think it's simple enough except for the environment case</p>



<a name="163758583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758583">(Apr 19 2019 at 19:24)</a>:</h4>
<p>This is tied in with "implied bounds", I'm not sure if that's a phrase you're familiar with?</p>



<a name="163758721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758721">(Apr 19 2019 at 19:26)</a>:</h4>
<p>I am now <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span> yeah that sounds logical, doesn't surprise me that there's some bounds that aren't explicitly stated</p>



<a name="163758842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758842">(Apr 19 2019 at 19:28)</a>:</h4>
<blockquote>
<p>as I recall, we were half-guessing when we wrote it ;)</p>
</blockquote>
<p>I'm often translating the rustc code just by looking at the types and seeing where I can plug in things, but maybe that's good enough in this case</p>



<a name="163758915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758915">(Apr 19 2019 at 19:29)</a>:</h4>
<p>the idea is something like this though</p>



<a name="163758965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758965">(Apr 19 2019 at 19:30)</a>:</h4>
<p>One thing that's also not clear yet is where this code will end up in Chalk, at the moment I'm still working in the <code>program_clauses_that_could_match</code> function, and just not using <code>self.environment()</code></p>



<a name="163758970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758970">(Apr 19 2019 at 19:30)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span>: <span class="nc">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span>: <span class="nc">Baz</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="163758978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758978">(Apr 19 2019 at 19:30)</a>:</h4>
<p>if you know have <code>where T: Foo</code>, you also know that <code>T: Bar</code> (and <code>T: Baz</code>)</p>



<a name="163758981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758981">(Apr 19 2019 at 19:30)</a>:</h4>
<p>so the loop is kind of elaborating those things</p>



<a name="163758998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163758998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163758998">(Apr 19 2019 at 19:30)</a>:</h4>
<p>I don't remember <em>precisely</em> but that's the general context</p>



<a name="163759002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759002">(Apr 19 2019 at 19:31)</a>:</h4>
<p>what loop are we talking about?</p>



<a name="163759030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759030">(Apr 19 2019 at 19:31)</a>:</h4>
<p>heh, good question. The last time I went looking for it I remember it took me a while to find it.</p>



<a name="163759144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759144">(Apr 19 2019 at 19:32)</a>:</h4>
<blockquote>
<p>One thing that's also not clear yet is where this code will end up in Chalk, at the moment I'm still working in the <code>program_clauses_that_could_match</code> function, and just not using <code>self.environment()</code></p>
</blockquote>
<p>this seems like a good way to start</p>



<a name="163759155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759155">(Apr 19 2019 at 19:32)</a>:</h4>
<p>Haven't looked yet, but the point is that there's a place where more clauses are added to the environment, right?</p>



<a name="163759254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759254">(Apr 19 2019 at 19:34)</a>:</h4>
<blockquote>
<p>heh, good question. The last time I went looking for it I remember it took me a while to find it.</p>
</blockquote>
<p>ok so the <em>main code</em> is here, <a href="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/chalk_context/program_clauses/mod.rs#L52-L56" target="_blank" title="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/chalk_context/program_clauses/mod.rs#L52-L56">the <code>program_clauses_impl</code> fn</a></p>



<a name="163759255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759255">(Apr 19 2019 at 19:34)</a>:</h4>
<p>however, it includes an <a href="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/chalk_context/program_clauses/mod.rs#L302" target="_blank" title="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/chalk_context/program_clauses/mod.rs#L302">innocuous looking line at the end</a></p>



<a name="163759263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759263">(Apr 19 2019 at 19:34)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">env_clauses</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">infcx</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">program_clauses_for_env</span><span class="p">(</span><span class="n">canonical_environment</span><span class="p">);</span><span class="w"></span>
</pre></div>



<a name="163759303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759303">(Apr 19 2019 at 19:35)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/lowering/environment.rs#L130-L133" target="_blank" title="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/lowering/environment.rs#L130-L133">that function is here</a></p>



<a name="163759304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759304">(Apr 19 2019 at 19:35)</a>:</h4>
<p>Ah, I see a <code>while !last_round.is_empty()</code> loop with a visitor</p>



<a name="163759318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759318">(Apr 19 2019 at 19:35)</a>:</h4>
<p>Yes.</p>



<a name="163759319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759319">(Apr 19 2019 at 19:35)</a>:</h4>
<p>As an aside, we really should have written more docs on these functions :)</p>



<a name="163759383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759383">(Apr 19 2019 at 19:36)</a>:</h4>
<p>but <a href="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/lowering/environment.rs#L90-L102" target="_blank" title="https://github.com/rust-lang/rust/blob/a2bbf7debaab60be33bd8008a71bca69576945a0/src/librustc_traits/lowering/environment.rs#L90-L102">this is an example of the code I was talking about above</a></p>



<a name="163759395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759395">(Apr 19 2019 at 19:36)</a>:</h4>
<p>Well, the doc is basically <span class="user-mention" data-user-id="116009">@nikomatsakis</span> and I :p</p>



<a name="163759399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759399">(Apr 19 2019 at 19:36)</a>:</h4>
<p>i.e., we look in the environment --- if we see <code>FromEnv(T: Foo)</code>, that means there is an in-scope where clause for <code>T: Foo</code>. In that case, we fetch the definition of <code>Foo</code> and add some of its clauses in there</p>



<a name="163759413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759413">(Apr 19 2019 at 19:37)</a>:</h4>
<p>so in the next round we would find <code>FromEnv(T: Bar)</code> in the list, which would cause us to cover <code>Baz</code></p>



<a name="163759418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759418">(Apr 19 2019 at 19:37)</a>:</h4>
<p>and so forth</p>



<a name="163759424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759424">(Apr 19 2019 at 19:37)</a>:</h4>
<blockquote>
<p>Well, the doc is basically <span class="user-mention silent" data-user-id="116009">nikomatsakis</span> and I :p</p>
</blockquote>
<p>Can I read you like a book, too?</p>



<a name="163759439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759439">(Apr 19 2019 at 19:37)</a>:</h4>
<p>there can be cycles here so we run until a fixed point</p>



<a name="163759528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759528">(Apr 19 2019 at 19:38)</a>:</h4>
<p>Ah ok, that's actually not too bad</p>



<a name="163759593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759593">(Apr 19 2019 at 19:39)</a>:</h4>
<p>At least, the complexity of it. Getting the ordering to be similar might be difficult</p>



<a name="163759620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759620">(Apr 19 2019 at 19:39)</a>:</h4>
<p>The ordering?</p>



<a name="163759623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759623">(Apr 19 2019 at 19:39)</a>:</h4>
<p>It shouldn't really matter what order</p>



<a name="163759695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759695">(Apr 19 2019 at 19:40)</a>:</h4>
<p>We are returning a vec, but the order of things in the vec are not that important</p>



<a name="163759710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759710">(Apr 19 2019 at 19:40)</a>:</h4>
<p>I meant visiting order, or doesn't that make a difference?</p>



<a name="163759755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759755">(Apr 19 2019 at 19:41)</a>:</h4>
<p>I don't think that should matter</p>



<a name="163759770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163759770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163759770">(Apr 19 2019 at 19:41)</a>:</h4>
<p>Ok, never mind then</p>



<a name="163760350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163760350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163760350">(Apr 19 2019 at 19:51)</a>:</h4>
<p>Thanks for the pointers, this gave me some confidence that I'm going the right way (and some context for the env part)</p>



<a name="163806868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163806868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163806868">(Apr 20 2019 at 15:06)</a>:</h4>
<p>Is canonicalization accessible outside of chalk_solve? all ways of canonicalizing seem to be <code>pub(crate)</code>, except for <code>GoalExt</code> which is "Useful for REPLs and tests but not much else".</p>



<a name="163865807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/163865807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#163865807">(Apr 21 2019 at 20:17)</a>:</h4>
<p>I've ported most of the env stuff over now, the tricky part is the type matches, since the variants don't match up. Very WIP PR: <a href="https://github.com/rust-lang/chalk/pull/216" target="_blank" title="https://github.com/rust-lang/chalk/pull/216">https://github.com/rust-lang/chalk/pull/216</a></p>



<a name="164061463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164061463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164061463">(Apr 24 2019 at 07:57)</a>:</h4>
<p>Rustc's <code>program_clauses_impl</code> does some filtering on <code>clause.category() == ProgramClauseCategory::WellFormed</code>, is there a Chalk-equivalent or does that need to be introduced?</p>



<a name="164061513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164061513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164061513">(Apr 24 2019 at 07:58)</a>:</h4>
<p>(most tests are failing on "trait impl for ... does not meet well-formedness requirements")</p>



<a name="164061703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164061703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164061703">(Apr 24 2019 at 08:02)</a>:</h4>
<p>Ah, missed the comments above <code>to_program_clauses</code>, so if I understand correctly, the relevant clauses are wrapped in <code>WellFormed</code> instead</p>



<a name="164156352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164156352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164156352">(Apr 25 2019 at 09:43)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> I was perusing your PR as I drank my morning coffee <span aria-label="coffee" class="emoji emoji-2615" role="img" title="coffee">:coffee:</span>  and I <a href="https://github.com/rust-lang/chalk/pull/216#pullrequestreview-230536153" target="_blank" title="https://github.com/rust-lang/chalk/pull/216#pullrequestreview-230536153">left some more notes here</a> -- make sense? </p>
<p>One thing I was wondering is how familiar you are with the clause lowering -- i.e., do you understand roughly the logic behind what these functions are doing? I'm not clear on how well this part of the picture has been explained.</p>



<a name="164156435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164156435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164156435">(Apr 25 2019 at 09:45)</a>:</h4>
<p>(Also, independently, I realized something as I was reading this over -- once we complete <em>this</em> work, I suspect we're going to want to do a bit more refactoring to introduce salsa here, so that we can plausibly have some caching. But this would be more of an optimization -- and it might make sense to push more on the RLS integration before doing it.)</p>



<a name="164167360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164167360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164167360">(Apr 25 2019 at 12:57)</a>:</h4>
<p>Great feedback! I actually also thought about doing the <code>retain</code>, but decided against it in case it was set up that way for performance reasons. But it makes sense to just simplify it</p>



<a name="164167564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164167564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164167564">(Apr 25 2019 at 13:00)</a>:</h4>
<blockquote>
<p>One thing I was wondering is how familiar you are with the clause lowering -- i.e., do you understand roughly the logic behind what these functions are doing? I'm not clear on how well this part of the picture has been explained.</p>
</blockquote>
<p>I must confess that some parts were translated by a mostly mechanical process of looking at the matched types and figuring out what the code is doing exactly. So there's probably some code there that's just plain wrong, and indeed I need to understand it a bit better.</p>



<a name="164177145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164177145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164177145">(Apr 25 2019 at 14:51)</a>:</h4>
<p>Ah, that's not very useful. let me try to write down my current understanding of the code, so that you can point out where my understanding is wrong/lacking</p>



<a name="164178454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164178454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164178454">(Apr 25 2019 at 15:05)</a>:</h4>
<p>The term lowering is already confusing, since it can mean both lowering AST to rust-ir, and rust-ir to logical rules (ProgramClauses, the one we're dealing with here)</p>



<a name="164178776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164178776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164178776">(Apr 25 2019 at 15:09)</a>:</h4>
<p>Ah I understand now, so both the database and the goal are talking about rust-ir, and we want to lower them both to logical rules to match them.</p>



<a name="164178895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164178895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164178895">(Apr 25 2019 at 15:10)</a>:</h4>
<p>Question: why can't we lower the goal itself first?</p>



<a name="164181303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164181303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164181303">(Apr 25 2019 at 15:35)</a>:</h4>
<p>As for the lowering itself: all the matching functions do in the end is just call the <code>to_program_clauses</code> for the ProgramClauses the goal is pointing at</p>



<a name="164182553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182553">(Apr 25 2019 at 15:48)</a>:</h4>
<blockquote>
<p>The term lowering is already confusing, since it can mean both lowering AST to rust-ir, and rust-ir to logical rules (ProgramClauses, the one we're dealing with here)</p>
</blockquote>
<p>well, lowering is just a general term for converting from one IR to another -- typically converting from some "high-level" IR to a more "low-level" IR</p>



<a name="164182595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182595">(Apr 25 2019 at 15:48)</a>:</h4>
<blockquote>
<p>Question: why can't we lower the goal itself first?</p>
</blockquote>
<p>the goal is .. lowered in some sense</p>



<a name="164182639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182639">(Apr 25 2019 at 15:48)</a>:</h4>
<p>in rust, you don't have explicit goals like "well-formed" or what have you</p>



<a name="164182667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182667">(Apr 25 2019 at 15:49)</a>:</h4>
<p>but basically we have these rules for converting bits of rust-ir into program clauses</p>



<a name="164182690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182690">(Apr 25 2019 at 15:49)</a>:</h4>
<p>each of those clauses can be used to prove some particular kind of domain-goal</p>



<a name="164182710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182710">(Apr 25 2019 at 15:49)</a>:</h4>
<p>so e.g. <code>impl Foo for Bar</code> generates a <code>Implemented(Bar: Foo) :- ...</code> clause</p>



<a name="164182783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182783">(Apr 25 2019 at 15:50)</a>:</h4>
<p>so what this code is doing is looking at the thing we have to prove and figuring out whihc bits of rust-ir <em>might</em> contribute a clause that could be useful</p>



<a name="164182814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182814">(Apr 25 2019 at 15:50)</a>:</h4>
<p>Right</p>



<a name="164182816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182816">(Apr 25 2019 at 15:50)</a>:</h4>
<p>(the old code just lowered <em>everything</em> first, but we're trying to be more selective)</p>



<a name="164182857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164182857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164182857">(Apr 25 2019 at 15:51)</a>:</h4>
<p>the <em>specifics</em> of how the code works, then, comes from taking a look at the actual rules and just trying to figure it out</p>



<a name="164183643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164183643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164183643">(Apr 25 2019 at 15:59)</a>:</h4>
<p>So why does Chalk's DomainGoal have so many more variants than rustc's? Is it because rustc computes more stuff on the side, while Chalk explicitly stores it inside the goal?</p>



<a name="164184842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164184842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164184842">(Apr 25 2019 at 16:14)</a>:</h4>
<p>Chalk's domain goal includes some experiments that we've not yet tried to integrate into rustc</p>



<a name="164184847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164184847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164184847">(Apr 25 2019 at 16:14)</a>:</h4>
<p>Nor fully finished, really</p>



<a name="164184853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164184853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164184853">(Apr 25 2019 at 16:14)</a>:</h4>
<p>We also model things (like coherence) that rustc doesn't yet model</p>



<a name="164184858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164184858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164184858">(Apr 25 2019 at 16:14)</a>:</h4>
<p>Which requires some new sorts of domain goals</p>



<a name="164352788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164352788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164352788">(Apr 27 2019 at 20:43)</a>:</h4>
<p>Hmm, so I'm trying to figure out why some of the tests are failing. Take the <code>fundamental_types</code> test for example:</p>
<div class="codehilite"><pre><span></span>goal { forall &lt; T &gt; { not { IsLocal ( Box &lt; T &gt; ) } } }
using solver: SLG { max_size: 10 }
expected:
No possible solution
actual:
Unique; substitution [], lifetime constraints []
</pre></div>


<p>Details aside, I'm a bit confused as to why it's finding more solutions.<br>
The logic for checking whether it's local and such should be done in <code>to_program_clauses</code>.<br>
But calling <code>to_program_clauses</code> on too many things should only give less solutions, not more, right?<br>
If so, could this be an uncovered problem in <code>to_program_clauses</code>?</p>



<a name="164352975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164352975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164352975">(Apr 27 2019 at 20:48)</a>:</h4>
<p>Ah, or maybe it's missing some clauses instead, and that's why there's more solutions</p>



<a name="164378727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164378727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164378727">(Apr 28 2019 at 09:33)</a>:</h4>
<blockquote>
<p>But calling <code>to_program_clauses</code> on too many things should only give less solutions, not more, right?<br>
If so, could this be an uncovered problem in <code>to_program_clauses</code>?</p>
</blockquote>
<p>not necessarily, because of negative logic</p>



<a name="164404091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164404091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164404091">(Apr 28 2019 at 19:56)</a>:</h4>
<p>That's weird, the environment seems to be empty...</p>



<a name="164404406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164404406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164404406">(Apr 28 2019 at 20:02)</a>:</h4>
<p>Ah yes, the old code was calling the <code>environment()</code> function in <code>query.rs</code>, and the <code>environment.clauses</code> that is used now in the <code>program_clauses</code> function is empty</p>



<a name="164404430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164404430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164404430">(Apr 28 2019 at 20:03)</a>:</h4>
<p>No wonder tests are failing, if env clauses like <code>IsLocal(Local)</code> are missing</p>



<a name="164468506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164468506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164468506">(Apr 29 2019 at 16:56)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125131">@detrumi</span> -- I'm wondering, would you like help with the "last mile" in <a href="https://github.com/rust-lang-nursery/chalk/issues/216" target="_blank" title="https://github.com/rust-lang-nursery/chalk/issues/216">chalk#216</a>?</p>



<a name="164468582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164468582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164468582">(Apr 29 2019 at 16:57)</a>:</h4>
<p>i.e., I was considering checking it out and pushing some commits, but didn't want to step on your toes</p>



<a name="164472323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164472323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164472323">(Apr 29 2019 at 17:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Yes, feel free to. I was a bit stuck on the environment stuff anyways, since that requires more knowledge of the high-level design</p>



<a name="164472573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164472573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164472573">(Apr 29 2019 at 17:45)</a>:</h4>
<p>And since this might be blocking rls2 integration, you working on it will help speed it up a bit (especially because the PR grew a bit in size)</p>



<a name="164485685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164485685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164485685">(Apr 29 2019 at 20:26)</a>:</h4>
<p>I've been fixing some of these cases FYI</p>



<a name="164485693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164485693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164485693">(Apr 29 2019 at 20:26)</a>:</h4>
<p>I just hit an interesting case (cc <span class="user-mention" data-user-id="131694">@scalexm</span>) --</p>



<a name="164485703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164485703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164485703">(Apr 29 2019 at 20:27)</a>:</h4>
<p>in particular if you have a goal like <code>?T: Send</code>, and this is an auto-trait, we need to enumerate <em>all</em> structs to find the rules</p>



<a name="164485715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164485715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164485715">(Apr 29 2019 at 20:27)</a>:</h4>
<p>I guess not that interesting</p>



<a name="164485727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164485727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164485727">(Apr 29 2019 at 20:27)</a>:</h4>
<p>for now I think I will add the helpers to do that, but also a FIXME to address this better with 'non-enumerable' goals</p>



<a name="164487243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164487243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164487243">(Apr 29 2019 at 20:46)</a>:</h4>
<p>OK, we're down to these errors</p>
<div class="codehilite"><pre><span></span>failures:
    test::coherence::downstream_impl_of_fundamental_43355
    test::coherence::fundamental_traits
    test::coherence::two_blanket_impls_open_ended
    test::fundamental_types
    test::gat_implied_bounds
    test::slg::cached_answers_1
    test::slg::cached_answers_2
    test::slg::cached_answers_3
    test::slg::contradiction
    test::slg::example_2_1_EWFS
    test::slg::example_2_2_EWFS
    test::slg::example_2_3_EWFS
    test::slg::example_3_3_EWFS
    test::slg::negative_answer_delayed_literal
    test::slg::negative_loop
    test::unselected_projection_with_gat
</pre></div>



<a name="164487245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164487245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164487245">(Apr 29 2019 at 20:46)</a>:</h4>
<p>I didn't try to look into coherence yet</p>



<a name="164487274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164487274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164487274">(Apr 29 2019 at 20:47)</a>:</h4>
<p>Oh, I bet I know what the slg* errors are</p>



<a name="164487576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164487576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164487576">(Apr 29 2019 at 20:50)</a>:</h4>
<p>OK, down to </p>
<div class="codehilite"><pre><span></span>failures:
    test::coherence::downstream_impl_of_fundamental_43355
    test::coherence::fundamental_traits
    test::coherence::two_blanket_impls_open_ended
    test::fundamental_types
    test::gat_implied_bounds
    test::slg::example_3_3_EWFS
    test::unselected_projection_with_gat
</pre></div>



<a name="164517888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164517888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164517888">(Apr 30 2019 at 07:32)</a>:</h4>
<p>Ah cool, didn't know of <code>PolarizedTraitRef</code></p>



<a name="164525401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164525401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164525401">(Apr 30 2019 at 09:46)</a>:</h4>
<p><span class="user-mention" data-user-id="125131">@detrumi</span> ok, tests pass now at least. Really makes me wonder if we could find a more automated way to do this. =)</p>



<a name="164568117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568117">(Apr 30 2019 at 19:27)</a>:</h4>
<p>Nice work getting the tests green <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="164568170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568170">(Apr 30 2019 at 19:28)</a>:</h4>
<p>Any work left for this PR, or is it mainly review + finishing things up?</p>



<a name="164568221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568221">(Apr 30 2019 at 19:28)</a>:</h4>
<p>I was just wondering about that</p>



<a name="164568244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568244">(Apr 30 2019 at 19:28)</a>:</h4>
<p>I <em>think</em> I'm inclined to land it roughly as is and then try to do further cleanups in separate PRs</p>



<a name="164568251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568251">(Apr 30 2019 at 19:28)</a>:</h4>
<p>I wasn't happy with how complex the <a href="http://clauses.rs" target="_blank" title="http://clauses.rs">clauses.rs</a> logic felt</p>



<a name="164568253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568253">(Apr 30 2019 at 19:28)</a>:</h4>
<p>That..might just be what it is :)</p>



<a name="164568267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568267">(Apr 30 2019 at 19:28)</a>:</h4>
<p>But I suspect we could at minimum refactor it a bit, and if not, we can at least document it better :)</p>



<a name="164568316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568316">(Apr 30 2019 at 19:29)</a>:</h4>
<p>Interestingly, this logic is actually "relevant" to the language spec -- or it will be -- because it will determine which specialization setups result in a cycle error and which do not</p>



<a name="164568328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568328">(Apr 30 2019 at 19:29)</a>:</h4>
<p>So it'd be nice to be able to document it more cleanly</p>



<a name="164568341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568341">(Apr 30 2019 at 19:29)</a>:</h4>
<p>Anyway, as I said, I suspect that's "future work"</p>



<a name="164568401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568401">(Apr 30 2019 at 19:30)</a>:</h4>
<p>Sure, but the rustc code here felt a bit hacky too, in places</p>



<a name="164568405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568405">(Apr 30 2019 at 19:30)</a>:</h4>
<p>Oh, indeed</p>



<a name="164568411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568411">(Apr 30 2019 at 19:30)</a>:</h4>
<p>It's no hackier than rustc</p>



<a name="164568418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568418">(Apr 30 2019 at 19:30)</a>:</h4>
<p>But definitely something to improve upon</p>



<a name="164568505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568505">(Apr 30 2019 at 19:31)</a>:</h4>
<p>Makes me wonder if we could express the <code>program_clauses</code> logic in some DSL and use that to derive <code>clauses.rs</code> too</p>



<a name="164568516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568516">(Apr 30 2019 at 19:31)</a>:</h4>
<p>but that's <em>definitely</em> future work :)</p>



<a name="164568669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164568669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164568669">(Apr 30 2019 at 19:33)</a>:</h4>
<p>A DSL? You mean some intermediate data structure that'd talk about what clauses to collect, without actually querying them from the database?</p>



<a name="164572270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572270">(Apr 30 2019 at 20:09)</a>:</h4>
<p>I don't know exactly what I mean :)</p>



<a name="164572341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572341">(Apr 30 2019 at 20:10)</a>:</h4>
<p>but in general the <a href="http://clauses.rs" target="_blank" title="http://clauses.rs">clauses.rs</a> logic feels like it ought to be automatically derivable</p>



<a name="164572364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572364">(Apr 30 2019 at 20:10)</a>:</h4>
<p>although, as I said, it has lang implications, so it's not clear to me</p>



<a name="164572374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572374">(Apr 30 2019 at 20:10)</a>:</h4>
<p><em>anyway</em>, yeah, let's land the PR</p>



<a name="164572395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572395">(Apr 30 2019 at 20:10)</a>:</h4>
<p><span class="user-mention" data-user-id="131694">@scalexm</span> -- do you happen to be around? do you want to look over <a href="https://github.com/rust-lang/chalk/pull/216" target="_blank" title="https://github.com/rust-lang/chalk/pull/216">https://github.com/rust-lang/chalk/pull/216</a> or are you happy if I just land it? :)</p>



<a name="164572883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164572883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164572883">(Apr 30 2019 at 20:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> could you wait tomorrow? I’ll give it a look in the morning</p>



<a name="164573159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164573159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164573159">(Apr 30 2019 at 20:19)</a>:</h4>
<p>Well anyway let’s land it, I’ll look at it in depth tomorrow and if anything stands out we can still make adjustments later, but I guess this won’t be necessary</p>



<a name="164573493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164573493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164573493">(Apr 30 2019 at 20:23)</a>:</h4>
<p>no great rush</p>



<a name="164573497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164573497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164573497">(Apr 30 2019 at 20:23)</a>:</h4>
<p>I think it can wait until tomorrow :)</p>



<a name="164825016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164825016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164825016">(May 03 2019 at 19:56)</a>:</h4>
<p><span class="user-mention" data-user-id="131694">@scalexm</span> I made the change you suggested, can I merge <a href="https://github.com/rust-lang/chalk/pull/216" target="_blank" title="https://github.com/rust-lang/chalk/pull/216">https://github.com/rust-lang/chalk/pull/216</a> ?</p>



<a name="164825034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164825034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164825034">(May 03 2019 at 19:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> yes looks good</p>



<a name="164825406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/164825406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#164825406">(May 03 2019 at 20:01)</a>:</h4>
<p>Merged, nice work <span class="user-mention" data-user-id="125131">@detrumi</span>!</p>



<a name="167603445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/chalk%20crates/near/167603445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/chalk.20crates.html#167603445">(Jun 07 2019 at 18:55)</a>:</h4>
<p>Hello - I'm interested in getting involved with this working group</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>